from aiogram_dialog import DialogManager

from src.config import Settings
from src.database.services import SubscriptionService
from src.database.services.user import UserService


async def user_info_getter(
    dialog_manager: DialogManager,
    user_service: UserService,
    subscription_service: SubscriptionService,
    **kwargs
):
    user_id: int = dialog_manager.event.from_user.id

    user = await user_service.get_user_by_telegram_id(user_id)
    user_subscription = await subscription_service.get_active_user_subscription(user_id)

    return {
        "user_id": user_id,
        "reg_date": user.created_at,
        "user_have_subscription": user_subscription,
    }


async def user_is_admin_getter(
    dialog_manager: DialogManager, config: Settings, **kwargs
):
    return {"is_admin": dialog_manager.event.from_user.id in config.tg_bot.admin_ids}
